package br.com.lambdacore.lang.reflect.mirror.matcher.impl;

import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;

import net.vidageek.mirror.dsl.Matcher;

public class AccessibleObjectMatcherAnnotationPresent<T extends AccessibleObject>
		implements Matcher<T> {

	private Class<? extends Annotation>[] annotationClasses;

	public AccessibleObjectMatcherAnnotationPresent(
			Class<? extends Annotation>... annotationClass) {
		this.setAnnotationClasses(annotationClass);
	}

	public boolean accepts(T element) {
		Class<? extends Annotation>[] annotationClasses = this
				.getAnnotationClasses();
		boolean isAnnotationPresent = false;
		for (Class<? extends Annotation> annotationClass : annotationClasses) {
			isAnnotationPresent |= element.isAnnotationPresent(annotationClass);
		}
		return isAnnotationPresent;
	}

	private Class<? extends Annotation>[] getAnnotationClasses() {
		return this.annotationClasses;
	}

	private void setAnnotationClasses(
			Class<? extends Annotation>[] annotationClasses) {
		this.annotationClasses = annotationClasses;
	}
}
